package com.smarthealthcare.patient.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.smarthealthcare.common.annotation.Log;
import com.smarthealthcare.common.core.controller.BaseController;
import com.smarthealthcare.common.core.domain.AjaxResult;
import com.smarthealthcare.common.enums.BusinessType;
import com.smarthealthcare.patient.domain.Beinhospital;
import com.smarthealthcare.patient.service.IBeinhospitalService;
import com.smarthealthcare.common.utils.poi.ExcelUtil;
import com.smarthealthcare.common.core.page.TableDataInfo;

/**
 * 病房列表Controller
 * 
 * @author ruoyi
 * @date 2024-11-22
 */
@RestController
@RequestMapping("/patient/patient")
public class BeinhospitalController extends BaseController
{
    @Autowired
    private IBeinhospitalService beinhospitalService;

    /**
     * 查询病房列表列表
     */
    @PreAuthorize("@ss.hasPermi('patient:patient:list')")
    @GetMapping("/list")
    public TableDataInfo list(Beinhospital beinhospital)
    {
        startPage();
        List<Beinhospital> list = beinhospitalService.selectBeinhospitalList(beinhospital);
        return getDataTable(list);
    }

    /**
     * 导出病房列表列表
     */
    @PreAuthorize("@ss.hasPermi('patient:patient:export')")
    @Log(title = "病房列表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Beinhospital beinhospital)
    {
        List<Beinhospital> list = beinhospitalService.selectBeinhospitalList(beinhospital);
        ExcelUtil<Beinhospital> util = new ExcelUtil<Beinhospital>(Beinhospital.class);
        util.exportExcel(response, list, "病房列表数据");
    }

    /**
     * 获取病房列表详细信息
     */
    @PreAuthorize("@ss.hasPermi('patient:patient:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(beinhospitalService.selectBeinhospitalById(id));
    }

    /**
     * 新增病房列表
     */
    @PreAuthorize("@ss.hasPermi('patient:patient:add')")
    @Log(title = "病房列表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Beinhospital beinhospital)
    {
        return toAjax(beinhospitalService.insertBeinhospital(beinhospital));
    }

    /**
     * 修改病房列表
     */
    @PreAuthorize("@ss.hasPermi('patient:patient:edit')")
    @Log(title = "病房列表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Beinhospital beinhospital)
    {
        return toAjax(beinhospitalService.updateBeinhospital(beinhospital));
    }

    /**
     * 删除病房列表
     */
    @PreAuthorize("@ss.hasPermi('patient:patient:remove')")
    @Log(title = "病房列表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(beinhospitalService.deleteBeinhospitalByIds(ids));
    }
}
